package com.buba.springcloud.service;

import com.buba.springcloud.entities.HfRegister;
import com.buba.springcloud.entities.HfStaff;
import com.buba.springcloud.mapper.HfstafMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class HfstafServiceImpl implements HfstafService {

    @Resource
    private HfstafMapper hfstafMapper;

    @Override
    public List<HfStaff> getHfstaff(String username,String name) {
        return hfstafMapper.getHfstaff(username,name);
    }

    @Override
    public int addHfregister(HfRegister hfRegister) {
        return hfstafMapper.addHfregister(hfRegister);
    }

    @Override
    public List<HfRegister> getRegister() {
        return hfstafMapper.getRegister();
    }

    @Override
    public int updRegister(Integer id) {
        return hfstafMapper.updRegister(id);
    }

    @Override
    public int hfRegister(Integer id) {
        HfRegister hfregister = hfstafMapper.getHfregister(id);
        Integer hfregister1 = hfstafMapper.updHfregister(id);
        HfStaff hfStaff = new HfStaff();
        hfStaff.setUsername(hfregister.getUsername());
        hfStaff.setName(hfregister.getName());
        hfStaff.setEmail(hfregister.getEmail());
        hfStaff.setPhone(hfregister.getPhone());
        hfStaff.setPassword(hfregister.getPassword());
        Integer hfregister2=hfstafMapper.addHfstaff(hfStaff);
        return hfregister2+hfregister1;
    }
}
